//
//  UITextField+ZSLimit.h
//  ZSLimitTextField-master
//
//  Created by safiri on 2018/7/2.
//  Copyright © 2018年 safiri. All rights reserved.
//

#import <UIKit/UIKit.h>

/// for characterSetLimitString: 身份证字符输入限制
#define IdCardCharacterSetString @"0123456789Xx\b"
/// for characterSetLimitString: 纯数字输入限制
#define NumberCharacterSetString @"0123456789\b";

typedef NS_ENUM(NSUInteger, UITextFieldZSLimitType) {
    LimitIdCardType = 1,
    LimitNumberType,
    LimitPhoneType, //11位纯数字手机号
    LimitPhoneSpaceType, //带空格格式的手机号输入：example 138 8888 8888
    LimitNumberEnglishAlphabet //只能输入数字和英文字母
};

@interface UITextField (ZSLimit)

/**
 最大长度。0为不限制长度
 */
@property (nonatomic ,assign)NSUInteger maxLength;


/**
 限制输入的字符，只能输入此字符串中的字符
 */
@property (nonatomic ,strong) NSString *characterLimitString;


/**
 限制输入的字符，可由 characterSetLimitString 设置
 */
@property (nonatomic ,strong) NSCharacterSet *characterLimitSet;


/**
 是否可以输入空格字符，默认不可以
 */
@property (nonatomic ,assign) BOOL canInputSpaceCharacter;

/**
 是否自动大写，默认为小写
 */
@property (nonatomic ,assign) BOOL isUppercaseString;


/**
 限制形式枚举
 */
@property (nonatomic ,assign) UITextFieldZSLimitType limitType;

- (BOOL)limitWithValueChangeString:(NSString *)string shouldChangeCharactersInRange:(NSRange)range;

/**
 实现 LimitPhoneSpaceType 样式
 */
- (BOOL)limitForPhoneSpaceTypeWithValueChangeString:(NSString *)string shouldChangeCharactersInRange:(NSRange)range;
@end
